package com.caishi.lkx.exam.question;

import cn.hutool.core.util.ObjectUtil;
import com.caishi.lkx.exam.model.QuestionModel;


/**
 * 判断题
 */
public class JudgmentDataProcess extends ObjectiveQuestionDataProcess<Integer> {
    @Override
    protected double computedAnswerQualityLevel(QuestionModel questionModel) {
        // 答案(5)：客观题结构化有答案5分、非结构化2分、无答案0分
        return Integer.valueOf(0).equals(questionModel.getAnswer()) || Integer.valueOf(1).equals(questionModel.getAnswer()) ? 5 : 0;
    }

    @Override
    protected double computedRightAnswerQualityLevel(QuestionModel questionModel) {
        // 正确答案(10)：客观题结构化有答案10分，非结构化有答案3分，无答案0分，
        return Integer.valueOf(0).equals(questionModel.getAnswer()) || Integer.valueOf(1).equals(questionModel.getAnswer()) ? 10 : 0;
    }

    @Override
    public boolean userAnswerIsRight(Integer rightAnswer, Integer userAnswer) {
        if (ObjectUtil.isEmpty(userAnswer)) return false;
        return userAnswer.equals(rightAnswer);
    }
}
